/**
 * Created by IntelliJ IDEA
 *
 * @author zhengjie
 * @Date:2022/1/7 11:37
 * @Version 1.0
 */
package com.zj.ssm.util;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class PermissionUtil {

    public static List<Map<String,Object>> haha(List<Map<String,Object>> hehe){
        List<Map<String,Object>> objects = new ArrayList<Map<String,Object>>();

        for (Map<String, Object> stringObjectMap : hehe) {
            if (stringObjectMap.get("type").equals("M")){
                List<Map<String,Object>> subMenu = new ArrayList<Map<String,Object>>();
                stringObjectMap.put("subMenu",subMenu);
                objects.add(stringObjectMap);
            }
        }
        for (Map<String, Object> stringObjectMap : hehe) {
            for (Map<String, Object> object : objects) {
                if (stringObjectMap.get("pid").equals(object.get("id"))){
                    ((List) object.get("subMenu")).add(stringObjectMap);
                }
            }
        }

        return objects;


    }
}
